package com.example.common.unit;


import cn.dev33.satoken.stp.StpUtil;
import com.example.module.user.vo.GetUserVO;
import org.springframework.stereotype.Component;

import java.sql.Date;

/**
 * @author ghy
 * @date 2025/08/19
 * @description 从Session中获取用户信息
 */
@Component
public class GetUserInfoBySessionUnit {
    /*
     * 获取所有用户信息
     *
     * @return GetUserVO
     * */
    public static GetUserVO getUser() {
        return ConvertUnit.DOToVO(StpUtil.getSession().get("user"), GetUserVO.class);
    }

    /*
     * 获取用户Id/手机号/名称/性别/密码/注册时间
     * */
    public static Long getUserId() {
        return getUser().getUserId();
    }

    public static String getUserPhone() {
        return getUser().getUserPhone();
    }

    public static String getUserName() {
        return getUser().getUserName();
    }

    public static String getUserSex() {
        return getUser().getUserSex();
    }

    public static String getUserPassword() {
        return getUser().getUserPassword();
    }

    public static Date getUserRegisterTime() {
        return (Date) getUser().getUserRegisterTime();
    }

}
